
package jard.webshop.nbp;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 *
 * @author cjp
 */
@Embeddable
public class Address implements Serializable {
    
    @Column(nullable=false)
    private String streetWithNumber;
    
    @Column(nullable=false)
    private Integer zipCode;
    
    @Column(nullable=false)
    private String area;
    
    public Address() {
    }

    public Address(String street, Integer zipCode, String area) {
        this.streetWithNumber = street;
        this.zipCode = zipCode;
        this.area = area;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (streetWithNumber != null ? streetWithNumber.hashCode() : 0);
        hash += (zipCode != null ? zipCode.hashCode() : 0);
        hash += (area != null ? area.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Address)) {
            return false;
        }
        Address other = (Address) object;
        if(this.streetWithNumber != null && 
          this.streetWithNumber.compareToIgnoreCase(other.streetWithNumber) != 0) 
        {
            return false;
        }
        if(this.zipCode != null && 
          this.zipCode != other.zipCode) 
        {
            return false;
        }
        if(this.area != null && 
          this.area.compareToIgnoreCase(other.area) != 0) 
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jard.webshop.nbp.Address[ " + streetWithNumber + ", " + zipCode + ", " + area + " ]";
    }

    /**
     * @return the streetWithNumber
     */
    public String getStreetWithNumber() {
        return streetWithNumber;
    }

    /**
     * @param streetWithNumber the streetWithNumber to set
     */
    public void setStreetWithNumber(String streetWithNumber) {
        this.streetWithNumber = streetWithNumber;
    }

    /**
     * @return the zipCode
     */
    public Integer getZipCode() {
        return zipCode;
    }

    /**
     * @param zipCode the zipCode to set
     */
    public void setZipCode(Integer zipCode) {
        this.zipCode = zipCode;
    }

    /**
     * @return the area
     */
    public String getArea() {
        return area;
    }

    /**
     * @param area the area to set
     */
    public void setArea(String area) {
        this.area = area;
    }
    
}
